package com.myStoreorderProvider.controller;

import entity.*;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import service.mystore.MyStoreorderService;

import java.util.Map;

/**
 * @author oahner
 * @create 2022-04-16 15:48
 */
@RestController
@RequestMapping("mystoreorder")
@CrossOrigin
public class MyStoreorderProviderController {

    private Logger logger = Logger.getLogger(getClass());

    @Autowired
    private MyStoreorderService myStoreorderService;


    /**
     * 获取我的门店订单列表
     * @param outorderPage
     * @return
     */
    @RequestMapping("getMyOutorder")
    public ResponseMessage getMyOutorder(@RequestBody Map<String,Object> outorderPage){
        logger.info("MyStoreorderProviderController getMyOutorder param:outorderPage="+outorderPage);
        ResponseMessage msg = myStoreorderService.getMyOutorder(outorderPage);
        logger.debug("MyStoreorderProviderController getMyOutorder result:msg="+msg);
        return msg;
    }

    /**
     * 获取我的门店订单列表
     * @param outorderinfo
     * @return
     */
    @RequestMapping("getMyOutorderInfo")
    public ResponseMessage getMyOutorderInfo(@RequestBody Outorderinfo outorderinfo){
        logger.info("MyStoreorderProviderController getMyOutorderInfo param:outorderinfo="+outorderinfo);
        ResponseMessage msg = myStoreorderService.getMyOutorderInfo(outorderinfo);
        logger.debug("MyStoreorderProviderController getMyOutorderInfo result:msg="+msg);
        return msg;
    }

    /**
     * 签收我的订单
     * @param outorder
     * @return
     */
    @RequestMapping("signMyOutorder")
    public ResponseMessage signMyOutorder(@RequestBody Outorder outorder){
        logger.info("MyStoreorderProviderController getMyOutorderInfo param:outorder="+outorder);
        ResponseMessage msg = myStoreorderService.signMyOutorder(outorder);
        logger.debug("MyStoreorderProviderController getMyOutorderInfo result:msg="+msg);
        return msg;
    }


    /**
     * 获取商品分类
     * @return
     */
    @RequestMapping("getProductCategory")
    public ResponseMessage getProductCategory(){
        logger.info("MyStoreorderProviderController getMyOutorderInfo init==================");
        ResponseMessage msg = myStoreorderService.getProductCategory();
        logger.debug("MyStoreorderProviderController getMyOutorderInfo result:msg="+msg);
        return msg;
    }


    /**
     * 根据分类获取商品
     * @return
     */
    @RequestMapping("getProductByCategory")
    public ResponseMessage getProductByCategory(@RequestBody Map<String,Object> productPage){
        logger.info("MyStoreorderProviderController getProductByCategory params:productPage="+productPage);
        ResponseMessage msg = myStoreorderService.getProductByCategory(productPage);
        logger.debug("MyStoreorderProviderController getProductByCategory result:msg="+msg);
        return msg;
    }

    /**
     * 下单（订单和详情）
     * @return
     */
    @RequestMapping("addStoreOrder")
    public ResponseMessage addStoreOrder(@RequestBody Map<String,Object> order){
        logger.info("MyStoreorderProviderController addStoreOrder params:order="+order);
        ResponseMessage msg = myStoreorderService.addStoreOrder(order);
        logger.debug("MyStoreorderProviderController addStoreOrder result:msg="+msg);
        return msg;
    }

    /**
     * 退货单
     * @param returnInfo
     * @return
     */
    @RequestMapping("addReturnOrder")
    public ResponseMessage addReturnOrder(@RequestBody Map<String, Object> returnInfo){
        logger.info("MyStoreorderProviderController addStoreOrder params:returnInfo="+returnInfo);
        ResponseMessage msg = myStoreorderService.addReturnOrder(returnInfo);
        logger.debug("MyStoreorderProviderController addStoreOrder result:msg="+msg);
        return msg;
    }


}
